/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Table 7 - Impacts on Women's Self-Reported Health
=========================================================================*/

use "$data/Final_Medellin_SisbenIV.dta", replace

	
	
global outcomes Enfermo_30 Acudio_Salud_30 Atendido_Salud_30 Discapacidad_Any Embarazada
	
		
mat a=J(5,4,.)
matrix rownames a =  $outcomes


local i=1
foreach var in $outcomes    {
	sum `var' if Niega==0
	mat 	a[`i',1] = r(mean)

	ivreghdfe `var'         (Niega=Mujer_Ponente)  , abs(oficina#time) cluster(id_juez) savefirst

	mat 	a[`i',2]  = _b[Niega]
	mat 	a[`i',3] = _se[Niega]

	mat 	a[`i',4] =e(N)


		
	local i=`i'+1
	}


mat lis a

	svmat2 a, rnames(outcome)
	
	drop if outcome==""
	
	rename a1 mean_nondenied
	rename a2 coef_femaleIV
	rename a3 se_femaleIV
	rename a4 N_femaleIV	
	
	
	keep outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	order outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	export excel using "$output/Tables paper matrices replication.xlsx", sheet("Table 7", modify) 
